package com.example.project7;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.example.project7.model.ListItem;

public class DetailActivity extends AppCompatActivity {
    private TextView tvTitle;
    private TextView tvContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        
        // 初始化控件
        tvTitle = findViewById(R.id.tv_title);
        tvContent = findViewById(R.id.tv_content);
        
        // 获取传递的数据
        ListItem item = (ListItem) getIntent().getSerializableExtra("list_item");
        if (item != null) {
            tvTitle.setText(item.getTitle());
            tvContent.setText(item.getContent());
        }
        
        // 设置标题栏
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setTitle("详情");
        }
    }
    
    @Override
    public boolean onSupportNavigateUp() {
        onBackPressed();
        return true;
    }
}